export default () => {
  // #ifdef H5
  // let url = window.location.href
  function getQueryParam(name = "debug") {
    const query = window.location.search.substring(1);
    const vars = query.split('&');
    for (let i = 0; i < vars.length; i++) {
      const pair = vars[i].split('=');
      if (decodeURIComponent(pair[0]) === name) {
        return decodeURIComponent(pair[1]);
      }
    }
    return null;
  }

  const debug = getQueryParam('debug');
  if (debug) {
    const script = document.createElement('script');
    script.src =
      'https://cdn-1251575231.cos.ap-shanghai.myqcloud.com/eruda/2.5.0/eruda.js';
    document.body.appendChild(script);
    script.onload = function () {
      // @ts-ignore
      eruda.init();
    };
  }
  // #endif
};
